<template>
  <view class="myPage">
    <view class="my_header" style="background: url('/static/my_bg.png');">
      <view class="my_header_content">
        <view class="avatar">
          <image class="avatarUrl" src="/static/svg/noNetwork.svg"></image>
        </view>
        <view class="nickName">昵称</view>
        <view class="messages">
          <image class="avatarUrl" src="/static/svg/messages.svg"></image>
        </view>
      </view>
      <view class="my_header_bottom">
        <view class="item">会员卡</view>
        <view class="item">优惠卡</view>
        <view class="item">订单</view>
      </view>
    </view>
    <view class="pageContentRow">
      <view class="itemRow" v-for="item in list">
        <view class="left">
          <image class="rowIcon" :src="item.icon"/>
          <text class="itemText">{{ item.text }}</text>
        </view>
        <view>
          <image class="rowIcon" src="/static/svg/rightArrow.svg" />
        </view>
      </view>
    </view>
    <view @click="clickEvent()">开发小程序</view>
    <image class="logo" src="/static/svg/no_data.svg"></image>
  </view>
</template>

<script setup>
import { onLoad, onShow } from "@dcloudio/uni-app";
import { shallowReactive } from "vue";
const clickEvent = (e)=>{
  console.log('clickEvent');
  uni.navigateTo({url:"/pages/login/index"})
}
const list = shallowReactive([
  {icon:"/static/svg/userAgreement.svg",text:'商家协议'},
  {icon:"/static/svg/costomer.svg",text:'平台留言'},
])
onShow(()=>{
  uni.authorize({
    scope: 'scope.userInfo',
    success(res) {
      uni.getUserInfo({
        success: function(res) {
          console.log(res.userInfo)
        }
      })
      console.log("userInfo===>res",res);
    }
  })
  uni.authorize({
    scope: 'scope.userLocation',
    success() {
      uni.showLoading({
        title: '加载中'
      })
      uni.getLocation({
        type:'wgs84',
        success: function (res) {
          console.log("res=====>",res);
          uni.hideLoading()
          // res.longitude
          // res.latitude
        },
        fail: function () {
          uni.hideLoading()
          uni.showToast({
            title: '获取地址失败，将导致部分功能不可用',
            icon:'none'
          });
        }
      })
    }
  })
  console.log("onShow");
})
</script>

<style lang="scss" scoped>
@import './index.scss';
.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}
</style>
